package com.qf.news.controller;

import com.qf.news.entity.NewsInfo;
import com.qf.news.service.NewsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 新闻信息表(NewsInfo)表控制层
 *
 * @author makejava
 * @since 2023-10-20 16:03:10
 */
@RestController
@RequestMapping("newsInfo")
@CrossOrigin
public class NewsInfoController {
    /**
     * 服务对象
     */
    @Autowired
    private NewsInfoService newsInfoService;

    /**
     * 根据新闻分类查询新闻列表
     * @return
     */
    @GetMapping("/listByTid")
    public List<NewsInfo> listByTid(Integer tid){
        System.out.println("查询" + tid + "分类下的新闻列表！");
        List<NewsInfo> result = newsInfoService.listByTids(tid);
        return result;
    }
}

